package ch.exm.storm.conditions;

import ch.exm.storm.query.relational.RelationalQuery;


public abstract class AbstractCondition implements Condition {

	protected StringBuilder whereCondition;
	public String getWhereStatement() {
		return whereCondition == null ? null : whereCondition.toString();
	}
	
	public And and(Condition condition) {
		return new And(this, condition);
	}

	public Or or(Condition condition) {
		return new Or(this, condition);
	}
	
	public final boolean evaluateRelationalCondition(RelationalQuery query) {
		return evaluateRelationalCondition(query, false);
	}
	
	/**
	 * Evaluate this condition
	 * @param query - The query against which this condition is evaluated
	 * @param inverse - True if it has to be evaluated the inverse of this condition
	 * @return true if this condition can be translated in a relational query, 
	 * false if it's necessary to evaluate it against the concrete object 
	 */
	protected abstract boolean evaluateRelationalCondition(RelationalQuery query, boolean inverse);
}
